feat(dwarf): DwarfHandling::Remap end-to-end (#143 DWARF Phase 2 inc 3b)#206
Merged
Conversation
Wire the v0.18.0 AddressRemap engine into a real `.debug_*` rewrite. `DwarfHandling::Remap` reads an input core module's DWARF, translates every code address to the fused code section, and re-serializes a single remapped set via `gimli::write::Dwarf::from`. Exposed as `meld fuse --dwarf remap`. Design (de-risked): - Recover the per-function instruction offset map POST-HOC by walking the input and final-output operator streams in lockstep, rather than capturing during the merge — so it reflects the adapter-wiring re-rewrite and threads no state through the hot path. A per-function operator-count / locals-prefix mismatch aborts the remap. - Correct-or-strip: `gimli::write::Dwarf::from` is all-or-nothing on addresses, used as the safety gate. Only the code-section base (address 0) is special-cased; any other unmapped address fails the conversion and falls back to stripping — never a wrong address. - Single DWARF source supported; multi-source inputs strip with a warning (merging independent unit sets deferred). Zero sources is a no-op. - Three-pass encode so remapped `.debug_*` land in the attestation/ provenance-hashed bytes (trailing custom sections don't shift code offsets). Verification: - New LS-D-1 (approved): wrong remapped address -> de-grounded downstream coverage/breakpoints. Gated by `dwarf::tests::ls_d_1_remap_translates_low_pc` -- a full gimli read->convert->write->read oracle asserting low_pc is actually translated. Plus the parallel-walk unit tests (identity + abort) and the multi-source strip-fallback integration test on lists.wasm. - Residual: `DW_AT_high_pc` as a length is copied verbatim (may be off by intra-function LEB drift); low_pc + line program are correct. Adds the `gimli` dependency. dwarf.rs Tier-5 registration follows in a separate workflow PR (byte-identical-workflow constraint). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
LS-N verification gate
Approved Failed LS entries(none) Missing regression tests
Updated automatically by |
avrabe
added a commit
that referenced
this pull request
May 29, 2026
`meld-core/src/dwarf.rs` (the DWARF AddressRemap engine + the `DwarfHandling::Remap` rewrite, #143) is correctness-critical: a wrong remapped code address silently de-grounds downstream coverage and breakpoints (LS-D-1). Add it to the Mythos auto-scan Tier-5 file list so future diffs get the clean-room AI delta pass. Standalone workflow-only change: the claude-code-action identity check requires the workflow file be byte-identical to main, so this cannot be bundled with the inc 3b code PR (#206). Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The final piece of DWARF Phase 2 (#143):
DwarfHandling::Remapturns theAddressRemapengine (v0.18.0) into a working, debug-info-preserving fusion path. It reads an input core module's.debug_*sections, translates every code address to the fused code section, and re-serializes a single remapped DWARF set viagimli::write::Dwarf::from. Exposed asmeld fuse --dwarf remap.This completes the increment arc:
code_range)InstrOffsetMap(LEB drift)AddressRemapengine (composes 1+2).debug_*rewrite +DwarfHandling::RemapDesign — three decisions that de-risk it
Post-hoc parallel operator walk. The instruction offset map is recovered by walking the input and final-output operator streams in lockstep, not captured during the merge. The merge re-rewrites bodies after adapter wiring (
lib.rs:694), so a captured map would go stale; the post-hoc walk reflects whatever rewriting actually happened and threads no state through the hot path. A per-function operator-count or locals-prefix mismatch (e.g. memory-rebasing inserted scratch ops) aborts the remap.Correct-or-strip.
gimli::write::Dwarf::fromis all-or-nothing on addresses — aNonefromconvert_addressaborts the whole conversion. That's used as the safety gate: only the structurally-invariant code-section base (address0) is special-cased; any other unmapped address fails the conversion and falls back to stripping. Never emit a wrong address.Single-DWARF-source scope. DWARF is per-input-core-module but the output has one code section. Merging N independent DWARF unit sets is a separate fidelity problem — deferred. Exactly one DWARF-bearing source → full remap; more than one → strip + warn; zero → no-op. The common single-component case (main module carries DWARF, hand-written adapter modules don't) is fully served.
A three-pass encode keeps the remapped
.debug_*inside the attestation/provenance-hashed bytes (trailing custom sections don't shift code offsets, so the remap built from pass A is valid for the final output).Verification
approved): wrong remapped DWARF address → de-grounded downstream coverage/breakpoints. Gated bydwarf::tests::ls_d_1_remap_translates_low_pc— a full gimli read→convert→write→read oracle that builds real input DWARF, remaps a subprogram'slow_pc, re-parses the output DWARF, and asserts the address was actually translated.lists.wasm.translate_*unit tests (3a) pin the remap math.tools/run_ls_verification.py:[ OK ] LS-D-1 (1 pass).Residual (documented in LS-D-1):
DW_AT_high_pcencoded as a length (DW_FORM_data*, the common Rust/LLVM encoding) is copied verbatim — gimli treats it as a constant, not an address — so a function's reported byte length may be off by intra-function LEB drift.low_pcand the line-number program (what debuggers andpulseengine/witnessuse) are correct.Notes
gimlidependency.dwarf.rsTier-5 registration is a separate follow-up PR (the claude-code-action byte-identical-workflow constraint forbids bundling amythos-auto.ymledit with code changes).🤖 Generated with Claude Code